User defined functions's  in VBA

How do you returen more than one value in  different datatypes in user defined functions?

please provide example for  function returen more than one value in different data types....


September 11th, 2015 1:26am

Hey you can store multiple values in lookup filed check out the following link

https://support.office.com/en-ca/article/Store-multiple-values-in-a-lookup-field-cd881efb-3a93-446c-89ca-e2199b600aa1

Free Windows Admin Tool Kit Click here and download it now
September 11th, 2015 2:35am

Hi rammi y,

I suppose you can refer to this code, either break things apart, so distinct methods return distinct values, or figure out a logical grouping and build an object to hold that data that can in turn be returned. (Quote: http://stackoverflow.com/questions/5339807/return-multiple-values-from-a-function-sub-or-type )

Private Type settings
    root As String
    path As String
    name_first As String
    name_last As String
    overwrite_prompt As Boolean
End Type


Public Sub Main()

    Dim mySettings As settings
    mySettings = getSettings()


End Sub

' if you want this to be public, you're better off with a class instead of a User-Defined-Type (UDT)
Private Function getSettings() As settings

    Dim sets As settings

    With sets ' retrieve values here
        .root = "foo"
        .path = "bar"
        .name_first = "Don"
        .name_last = "Knuth"
        .overwrite_prompt = False
    End With

    ' return a single struct, vb6/vba-style
    getSettings = sets

End Function

If you have more questions about VBA, I suggest you post your question to MSDN for Developers Forum:
https://social.msdn.microsoft.com/Forums/en-US/home?category=officedev&filter=alltypes&sort=lastpostdesc

The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

Hope it's helpful.

Regards,

Emi Zhang
TechNet Community Su

September 13th, 2015 11:15pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics